package cn.bytecollege.admin.controller;

import cn.bytecollege.admin.service.CuisineService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "CuisineDeleteController",value = "/admin/cuisineDelete")
public class CuisineDeleteController extends HttpServlet {
    private CuisineService cuisineService=null;

    public CuisineDeleteController() {
        cuisineService=new CuisineService();
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=request.getParameter("id");
        Integer cuisineId=Integer.valueOf(id);

        cuisineService.deleteById(cuisineId);

        response.sendRedirect(request.getContextPath()+"/admin/cuisineList");
    }
}
